#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    QPushButton* btn = new QPushButton("这是一个被禁用的按钮", this);
    btn->setEnabled(false);
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    qDebug()<<"按下按钮";
}


void Widget::on_pushButton_2_clicked()
{
    bool flag = this->ui->pushButton->isEnabled();
    if(flag)
    {
        this->ui->pushButton->setText("不可点击，已被禁用");
        this->ui->pushButton->setEnabled(false);
    }
    else
    {
        this->ui->pushButton->setText("可点击");
        this->ui->pushButton->setEnabled(true);
    }
}

